package site.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.n3r.eql.Eql;
import org.n3r.eql.EqlPage;
import org.springframework.stereotype.Service;

import site.obj.YearsCounts;

import com.google.common.collect.ImmutableMap;

@Service
public class ValuationService {

    public Boolean insertEvaluate(Map map) {
        Integer count = new Eql().insert("addEvaluate").params(map).execute();
        if (1 != count) {
            return false;
        }
        return true;
    }

    public Boolean updateEvaluate(Map map) {
        Integer count = new Eql().insert("updateEvaluate").params(map).execute();
        if (1 != count) {
            return false;
        }
        return true;
    }

    public Boolean delEvaluate(String evalId) {
        Integer count = new Eql().update("delEvaluate").params(evalId).execute();
        if (0 > count) {
            return false;
        }
        return true;
    }

    public Map queryEvaluate(String evalId) {
        return new Eql().selectFirst("queryEvaluate").params(ImmutableMap.of("evalId", evalId))
                .returnType(HashMap.class).execute();
    }

    public List<Map> queryEvaluates(EqlPage eqlPage) {
        return new Eql().id("queryEvaluate").returnType(HashMap.class).limit(eqlPage).execute();
    }

    public List<YearsCounts> queryEvalYears() {
        return new Eql().select("queryEvalYears").returnType(YearsCounts.class).execute();
    }

    public List<Map> queryEvalList(String creatDate, EqlPage eqlPage) {
        return new Eql().id("queryEvalList").params(creatDate).returnType(HashMap.class).limit(eqlPage).execute();
    }
}
